import org.junit.Test;
import spring.calculator.Calculator;
import spring.calculator.CalculatorStaticProxy;
import spring.calculator.CalulatorImpl;
import spring.calculator.ProxyFactory;

/**
 * @author Yancy xiao
 * @create 2022-11-19 15:59
 */
public class proxytest {
    @Test
    public void test() {
        CalculatorStaticProxy calculatorStaticProxy = new CalculatorStaticProxy(new CalulatorImpl());
        int add = calculatorStaticProxy.add(1, 2);
        System.out.println(add);
    }

    @Test
    public void testdynamicProxy() {
        ProxyFactory proxyFactory = new ProxyFactory(new CalulatorImpl());
        Calculator proxy = (Calculator) proxyFactory.getProxy();
        int s = proxy.add(1, 2);
        System.out.println(s);
    }
}
